package cn.bob.basic.controller;

import cn.bob.basic.dto.LoginDto;
import cn.bob.basic.dto.RegisterDto;
import cn.bob.basic.utils.AjaxResult;
import cn.bob.basic.service.IVerifyCodeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @author bob
 * @data 2022/10/18-15:16
 */
@RestController
@RequestMapping("/verifyCode")
@Slf4j
public class VerifyCodeController {
    @Autowired
    private IVerifyCodeService service;


    @GetMapping("/image/{key}")
    public AjaxResult graph(@PathVariable("key") String uuidkey){
        String graph = service.graph(uuidkey);
        return AjaxResult.me().success(graph);
    }



    @PostMapping("/smsCode")
    public  AjaxResult smsCode(@RequestBody  RegisterDto registerDto){
        service.smsCode(registerDto);
        return AjaxResult.me().success();
    }
    @PostMapping("/smsCode/email")
    public  AjaxResult smsCodeEmail(@RequestBody  RegisterDto registerDto){
        service.smsCodeEmail(registerDto);
        return AjaxResult.me().success();
    }
    @PostMapping("/smsCodeLogin")
    public  AjaxResult smsCodeLogin(@RequestBody  LoginDto registerDto){
        service.smsCodeLogin(registerDto);
        return AjaxResult.me().success();
    }
}
